/*
 * ServerNode.cpp
 *
 *  Created on: Apr 22, 2013
 *      Author: root
 */

#include "CdnServerNode.h"
/*
 * ServerNode initi
 */
CdnServerNode::CdnServerNode():CdnArea(SVRNODE)
{
	prev = NULL;
	next = NULL;
	memset(key,'\0',sizeof(key));
	key_index = 0;
	hash_prev= NULL;
	hash_next= NULL;
}
/**
 * ServerNode free
 */
CdnServerNode::~CdnServerNode()
{
	/*
	 * add your code here
	 */
}

/**
 * add child not support
 */
int CdnServerNode::ApendChildToLast(CdnArea * pNode)
{
	return FAILURE;
}

/**
 * Update  cdn sever Node config Info
 */
int CdnServerNode::UpdateSvrNodeInfo(const char * pname,
		int ntype,
		int ispid,
		int svrflag,
		int svrmaxconnectcount,
		const char * wanlp,
		const char *lanip)
{
	this->SetName(pname);
	this->nodetype = ntype;
	this->isp = ispid;
	this->service_flag = ispid;
	this->max_connect_count = svrmaxconnectcount;

	if(wanlp != NULL)
		this->wan_ip = inet_addr(wanlp);
	if(lanip != NULL)
		this->lan_ip = inet_addr(lanip);

	return SUCCESS;
}

/*
* Update  cdn sever Node run  Info by heatbeat notice
*/
int CdnServerNode::CdnNodeHeartBeatUpdate(const char * data,int flag)
{
	return SUCCESS;
}

/*
 * node properties
 */
int CdnServerNode::GetNodeType()
{
	return this->nodetype;
}
int CdnServerNode::GetIsp()
{
	return this->isp;
}
int CdnServerNode::GetServiceFlag()
{
	return this->service_flag;
}
int CdnServerNode::GetStatus()
{
	return this->status;
}
int CdnServerNode::GetCpuUse()
{
	return this->cpu_use;
}
int CdnServerNode::GetMemoryUse()
{
	return this->memory_use;
}
int CdnServerNode::GetMaxConnectCount()
{
	return this->max_connect_count;
}
int CdnServerNode::GetCurrentConnectCount()
{
	return this->current_connect_count;
}
uint32_t CdnServerNode::GetWanIpAddress()
{
	return this->wan_ip;
}
uint32_t CdnServerNode::GetLanIpAddress()
{
	return this->lan_ip;
}
uint64_t CdnServerNode::GetDiskTotalSpace()
{
	return this->total_disk_space;
}
uint64_t CdnServerNode::GetDiskFreeSpace()
{
	return this->free_disk_space;
}
uint64_t CdnServerNode::GetSendBandWidth()
{
	return this->send_band_width;
}
uint64_t CdnServerNode::GetRecvBandWidth()
{
	return this->recv_band_width;
}
time_t	CdnServerNode::GetLastHeartBeatTime()
{
	return this->last_heart_beat_time;
}
time_t	CdnServerNode::GetLastDataSyncTime()
{
	return this->last_data_sync_time;
}

